package com.wing.productionPlan.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wing.productionPlan.model.entity.ProductionWorkOrder;
import com.wing.productionPlan.model.request.ProductionWorkOrderForm;
import com.wing.productionPlan.model.response.*;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 生产开工单-Service
 *
 * @author
 */
public interface ProductionWorkOrderService extends IService<ProductionWorkOrder> {

    /**
     * 添加
     *
     * @param productionWorkOrderForm
     * @return
     */
    int add(ProductionWorkOrderForm productionWorkOrderForm);

    /**
     * 列表-app
     *
     * @param params
     * @return
     */
    List<ProductionWorkOrderVO> list4app(Map<String, Object> params);

    /**
     * 分页list-app
     *
     * @param page
     * @param params
     * @return
     */
    Page<ProductionWorkOrderVO> pageList4app(Page page, Map<String, Object> params);

    /**
     * 详情-app
     *
     * @param id
     * @return
     */
    ProductionWorkOrderVO get4appById(Long id,String workOrderCode);

    /**
     * 查询工单列表
     *
     * @param productionWorkOrderVO
     * @param page
     * @param limit
     * @return
     */
    IPage<ProductionWorkOrderVO> getProductionWorkOrderVOPageList(ProductionWorkOrderVO productionWorkOrderVO, Integer page, Integer limit);

    /**
     * 上移或者下移工单
     *
     * @param id
     * @param operaType
     */
    void moveWorkOrder(Long id, Integer operaType);

    /**
     * 工单明细
     *
     * @param id        工单id
     * @param processId 工序id
     * @param skuCode   产品编码
     * @return
     */
    WorkOrderInfoVO getWorkOrderInfo(Long id, Long processId, String skuCode, String deviceCode);

    /**
     * 工单的激活、暂停、关闭
     *
     * @param id
     * @param type
     */
    void operationWorkOrder(Long id,Long recordId, Integer type);

    /**
     * 查询设备是否有生产中的工单
     *
     * @param deviceCode
     * @return
     */
    ProductionWorkOrder getDeviceProductionOrder(String deviceCode);

    /**
     * 添加工单
     *
     * @param productionWorkOrderForm
     */
    void submitWorkOrder(ProductionWorkOrderForm productionWorkOrderForm);

    /**
     * @param workOrderId
     * @return
     */
    ProductionWorkOrderVO getWorkOrderDetails(Long workOrderId,String workOrderCode);

    /**
     * 工站生产任务列表
     *
     * @param page
     * @param limit
     * @return
     */
    IPage<ProductionWorkStationVO> getProductionWorkStationVOPageList(Integer page, Integer limit);

    /**
     * 获取开工单详情
     * @param orderId 工单id
     * @return
     */
    ProductionWorkOrderDetailVO getDetailBy(Long orderId);

    /**
     *
     * @param workId
     * @return
     */
    Long getProcessIdForWork(Long workId);

    /**
     * 查询当前报工单是否需要质检
     * @return
     */
    String getIsNeedQuality(Long workOrderId);

    String getQualityAttributes(Long workOrderId);

    /**
     * 查詢工序類型
     * @param workOrderId
     * @return
     */
    String getTypeLies(Long workOrderId);

    /**
     * 查询上一道工序的一些信息
     * @param orderId
     * @return
     */
    Map<String, Object> getUpOneInfo(Long orderId);

    /**
     * 查询工艺流程卡信息
     * @param id
     * @return
     */
    ProcessCardInfoVo getProcessCardBy(Long id);


    ProWorkOrderPrintVo getWorkOrderPrint(Long id);


    /**
     * 获取末工序的报工数量
     * @param productionPlanRecordId
     * @return
     */
    Integer getLastReportInfoBy(Long productionPlanRecordId);
}
